using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TouchSource : MonoBehaviour
{
    public PlayerElement element;
    public Player_FSM PlayerFsm;
    public void switchElement()
    {
        PlayerFsm.SwitchElement(element);
    }
	private void OnCollisionStay2D(Collision2D collider)
    {
	if (collider.gameObject.tag == "Player")
		{
			if(PlayerFsm.PreIsTouch)
			{
				PlayerFsm.IsTouch = false;
				return;
			}
			else
			{
				PlayerFsm.PreIsTouch = true;
				if (PlayerFsm.currentEle != element)
        		{
					PlayerFsm.IsTouch = true;
            		switchElement();
        		}
			}
		}
   }
	private void OnCollisionExit2D(Collision2D collider)
    {
		PlayerFsm.IsTouch = false;
		PlayerFsm.PreIsTouch = false;
    }
}
